package com.core.gui.dialogs;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import com.core.database.Manager;

public class Main {

	/**
	 * @param args
	 * @throws SQLException 
	 */
	
	public static void main(String[] args) throws SQLException {
		try {

			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (UnsupportedLookAndFeelException e) {
			// handle exception
		} catch (ClassNotFoundException e) {
			// handle exception
		} catch (InstantiationException e) {
			// handle exception
		} catch (IllegalAccessException e) {
			// handle exception
		}
		
		Connection connection = Manager.getConnection();
		String stringRole = "admin";
		String sql = "SELECT role FROM username WHERE role = ?";
		PreparedStatement ps = connection.prepareStatement(sql);
		ps.setString(1, stringRole);
		ResultSet rs = ps.executeQuery();
		boolean authenticated = false;
		if (rs.next()) {
			authenticated = true;
			new LoginDialog().setVisible(true);
		} else {
			new RegistrationDialog().setVisible(true);
		}

	}

}
